<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<block th:replace="commonBase"></block>   
</head>
<style type="text/css">   
    .asLabel .mini-textbox-border,
    .asLabel .mini-textbox-input,
    .asLabel .mini-buttonedit-border,
    .asLabel .mini-buttonedit-input,
    .asLabel .mini-textboxlist-border
    {
        border:0;background:none;cursor:default;
    }
    .asLabel .mini-buttonedit-button,
    .asLabel .mini-textboxlist-close
    {
        display:none;
    }
    .asLabel .mini-textboxlist-item
    {
        padding-right:8px;
    }    
    .mini-tree .mini-tree-icon { /*树形节点图标颜色*/
	    font-size: 16px;
	    line-height: 22px;
	    text-align: left;
	    color: #79C4E8;     
    }
    .mini-tree-leaf:before {     /*选中叶子节点的图标颜色*/
        content: "\f15b";
        color: #79C4E8;   
    }
    .mini-tree-folder:before {   /*选中非叶子节点的图标颜色*/
        content: "\f07b";
        color: #79C4E8;   
    }
   .mini-panel-border{
        border:none;     
    }   
    
    .mini-grid-border{    
        border:none;     
    }      
    
</style>     
<link th:href="@{/hplus/css/plugins/layui/css/layui.css?v=4.1.0}" rel="stylesheet" />  
<script th:src="@{/hplus/js/jquery.min.js?v=2.1.4}"></script>     
<script th:src="@{/hplus/css/plugins/layui/layui.js}"></script>       
<body>
    <div class="mini-splitter" handlerSize="3"  style="width:100%;height:100%;">
      <!-- 左部查询树开始 -->         
	  <div size="20%" showCollapseButton="false"> 
	    <div style="height:35px;line-height:35px;border:1px solid #DDDDDD;font-size:20px;font-weight:bold">
	                   请选择检查项目      
	    </div>   
        <table>       
          <tr height="35px"><td> <input id="zqCode" class="mini-combobox" style="width:100%;" valueField="zqCode" textField="zqName" allowInput="false" showNullItem="false" onvaluechanged="orgChange()"/></td></tr>
          <tr height="35px"><td><input id="roadType" class="mini-combobox" style="width: 100%;" valueField="roadTypeCode" textField="roadTypeName" allowInput="false" showNullItem="false" onvaluechanged="queryTreeData()"/></td></tr>
        </table>                              
		<div class="mini-fit">
			<ul id="tree1" class="mini-tree" style="width:100%;"
				showTreeIcon="true" textField="projectPrefs" idField="id" expandOnLoad="-1" onnodeclick="clickTree()"
				parentField="pid" resultAsTree="false"  allowDrag="true" allowDrop="true">   
			</ul>  
		</div> 
     </div>
     <!-- 左部查询树结束 -->
     <!-- 右部查询列表开始 -->
     <div showCollapseButton="false" >
        <div id="dataGridTip" style="height:35px;line-height:35px;border:1px solid #DDDDDD;font-size:20px;font-weight:bold">
	                   项目评分列表   
	    </div>     
		<!-- 列表展示开始 -->
		<div class="mini-fit">
			<div id="grid1" class="mini-datagrid" style="width:100%;height:100%;display:none" 
				allowCellSelect="true" multiSelect="true" allowAlternating="false" sortField="id" sortOrder="asc" idField="id" pageSize="20" sizeList="[10,20,50,100]">
				<div property="columns">
					<div field="id" width="100" headerAlign="center" align="left">编号</div>
					<div field="projectPrefs" width="100" headerAlign="center" align="left">项目描述</div>
					<div field="inScores" width="100" headerAlign="center" align="left">分值</div>
				</div>
			</div>  
			      
			<div id="oneContent" style="width:100%;height:100%;display:none" >   
			    <div style="height:35px;line-height:35px;border:1px solid #DDDDDD;font-size:20px;font-weight:bold">评分结果</div>
			    <div style="height:35px;line-height:35px;font-size:16px">
				            检查项目：<span id="checkName"></span> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;    
				    <span>检查日期&nbsp;</span><input id="checkDate" class="mini-datepicker"  format="yyyy-MM-dd" onvaluechanged="checkDateChange()"/>  
				    &nbsp;&nbsp;&nbsp;&nbsp;<span>检查得分&nbsp;</span>
				   <!--  <input id="sole-input" oninput="searchInputChange()" onporpertychange="searchInputChange()"  class="searchbox-content-common" type="text" name="word" autocomplete="off" maxlength="256"  style="font-size:14px;font-family:Arial,Helvetica,SimSun,sans-serif;"  placeholder="请输入路线编码或名称" value=""></input> -->
				    <input id="checkScore" class="mini-textbox" onblur="checkScoreData()"/>
			    </div>                    
			    <div style="height:35px;line-height:35px;border:1px solid #DDDDDD;font-size:20px;font-weight:bold">评分内容</div>   
			    <div style="height:40%;overflow:auto">    
			       <div style="font-size:16px;font-weight:bold">检查内容</div>
			       <div id="checkContent" style="margin-bottom:3px"></div>
			       <div style="font-size:16px;font-weight:bold">评分标准</div>
			       <div id="checkStand" style="margin-bottom:3px"></div>         
			       	<div style="font-size:16px;font-weight:bold">评分细则</div>
			       <div id="checkMain"></div>
			    </div>          
			    <div style="height:35px;line-height:35px;border:1px solid #DDDDDD;font-size:20px;font-weight:bold">评分记录</div>
			    <div style="height:25%;">待开发...</div>      
			</div>      
		 </div>
		 <!-- 列表展示结束 -->
	   </div>
    </div>	
    
    <div style="display:none"> 
	    <input class="mini-hidden" id="limitScore"/>     
    </div>  	      
	

             
</body>

<script th:inline="javascript" type="text/javascript">
 /*<![CDATA[*/
    mini.parse();
    var grid =  null;//表格对象
	var tree = null;//树对象
	$(function(){
		initCondition();    //初始化
		grid = mini.get("grid1");
		tree = mini.get("tree1");
		queryTreeData();
	})
	
	function savaOrUpdateGrade(){
		var checkScore = mini.get("checkScore").getValue().trim();
		var checkDate = mini.get("checkDate").getValue();       
		if(null != checkScore && checkScore.length > 0 && null != checkDate && "" !=checkDate){
			var fileNode = tree.getSelectedNode();
			var id = fileNode.id;
			var roadType = mini.get("roadType").getValue();
	 		var zqCode = mini.get("zqCode").getValue();
			$.ajax({
				 url:basePath+"gjGrade/savaOrUpdateGrade",
				 type: 'POST',
			     data:{"id":id,"zqCode":zqCode,"roadType":roadType,"checkScore":checkScore,"checkDate":checkDate},   
				 success : function(data) { 
				  
				 },  
				 error : function() {    
					showMsg("保存数据错误，请稍后重试","danger",1200,"center","center");
				 }
			});
		}
	}
	
	function checkDateChange(){
		var checkDate = mini.get("checkDate").getValue();
		if(null != checkDate && "" !=checkDate ){            
			checkScoreData();       
		}
	}
	
	function checkScoreData(){ 
		var checkScore = mini.get("checkScore").getValue().trim();  
		if(checkScore.length > 0){  
		   var patrn = /^\d+(\.\d+)?$/;
       	   if (!patrn.exec(checkScore)){
       		  mini.alert("请输入合法的分值","温馨提示");  
       	      return;
       	   }     
		   var limitScore = mini.get("limitScore").getValue();
		   var limitScoreArr = limitScore.split(",");      
		   if(limitScoreArr.length > 1){  
			   var flag = false;
			   for(var i = 0;i < limitScoreArr.length;i++){
				   if(limitScoreArr[i] == checkScore){
					   flag = true;
					   break;
				   }
			   }
			   if(!flag){
				   mini.alert("分值的可输范围为："+limitScore,"温馨提示");  
		       	   return;
			   }
		   }else{
			   if(checkScore > limitScoreArr[0]){
				   mini.alert("分值的可输范围为：0-"+limitScoreArr[0],"温馨提示");  
		       	   return;         
			   }
		   }
		   savaOrUpdateGrade();
		}           
	}
	
	function orgChange(){
		var fileNode = tree.getSelectedNode();
        if(tree.isLeaf(fileNode)){      //选中的是叶子节点才加载数据
        	loadGradeData();   
        }
	}
	
	function loadGradeData(){
		var fileNode = tree.getSelectedNode();
		var id = fileNode.id;
		var projectPrefs = fileNode.projectPrefs;
		var roadType = mini.get("roadType").getValue();
 		var zqCode = mini.get("zqCode").getValue();
 		$.ajax({
			 url:basePath+"gjGrade/loadGradeData",
			 type: 'POST',
		     data:{"id":id,"zqCode":zqCode,"roadType":roadType},   
			 success : function(data) { 
			    data = mini.decode(data); 
			    if(null == data || data.length == 0){                
			    	mini.get("checkDate").setValue(formatDate(new Date()));   
			    	mini.get("checkScore").setValue("");      
			    }else{                   
			    	mini.get("checkDate").setValue(formatDate(data[0].checkDate));   
			    	mini.get("checkScore").setValue(data[0].checkScore);   
			    }
			 },  
			 error : function() {    
				showMsg("获取"+projectPrefs+"错误，请稍后重试","danger",1200,"center","center");
			 }
		});
	}
	
	function loadOneDetail(){
		var fileNode = tree.getSelectedNode();
		var id = fileNode.id;
		var pid = fileNode.pid;
		var projectPrefs = fileNode.projectPrefs;
		var roadType = mini.get("roadType").getValue();
		$.ajax({
			 url:basePath+"checkRecord/getOneDetailData",
			 type: 'POST',
		     data:{"id":id,"pid":pid,"roadType":roadType},   
			 success : function(data) {
			    if(null != data){          
			    	data = mini.decode(data);                
			    	$("#checkName").text(data[0].projectPrefs);      
			    	$("#checkContent").html(data[0].checkContent);      
			    	$("#checkStand").html(data[0].checkStand);      
			    	$("#checkMain").html(data[0].checkMain); 
			    	mini.get("limitScore").setValue(data[0].inScores);      
			    }
			 },  
			 error : function() {    
				showMsg("获取"+projectPrefs+"错误，请稍后重试","danger",1200,"center","center");
			 }
		});
	}
	
	function clickTree(){
		var fileNode = tree.getSelectedNode();
        if(tree.isLeaf(fileNode)){      //叶子节点，展示点击项的具体信息
        	$("#grid1").css({"display":"none"});
        	$("#dataGridTip").css({"display":"none"});
        	$("#oneContent").css({"display":"block"}); 
        	loadOneDetail();     
        	loadGradeData();
        }else{  //展示此节点的叶子节点列表
        	$("#oneContent").css({"display":"none"});
        	$("#dataGridTip").css({"display":"block"});    
        	$("#grid1").css({"display":"block"});
        	var pid = fileNode.id;
        	var roadType = mini.get("roadType").getValue();
        	var url = basePath + "checkRecord/getDataGridByPid";
        	grid.setUrl(url);         
        	grid.load({"pid":pid,"roadType":roadType});         
        }                  
	}
	
	//查询左侧树形列表数据
	function queryTreeData(){
		var roadType = mini.get("roadType").getValue();
		$.ajax({
			 url:basePath+"checkRecord/getTreeGridData",
			 type: 'POST',
		     data:{"roadType":roadType},   
			 success : function(text) {
				var fileNameList = mini.decode(text);
				tree.loadList(fileNameList, "id", "pid");     
				var nodeArr = tree.getList();      
				tree.selectNode(nodeArr[0]);   
				clickTree();      
			 },  
			 error : function() {    
				showMsg("获取菜单树错误，请稍后重试","danger",1200,"center","center");
			 }
		});
	}    
	
	function initCondition(){
		var roadTypeData = [{"roadTypeCode":"H","roadTypeName":"高速公路"},{"roadTypeCode":"P","roadTypeName":"普通公路"}];  
		mini.get("roadType").setData(roadTypeData);  
		mini.get("roadType").select(0);      
		mini.get("zqCode").setUrl(basePath + "gjArea/getAllList");
		mini.get("zqCode").select(0);     
	}
	
	function formatDate(date){
		if(date == null || date.length == 0){
			return "";    
		}
		return format(date, 'yyyy-MM-dd');
	}
	
	
	/* layui.use('layedit', function(){
	  var layedit = layui.layedit,
	  $ = layui.jquery;       
	  
	  //构建一个默认的编辑器
	  var index = layedit.build('LAY_demo1', {
		  height: 180 //设置编辑器高度
	  });    
	  
	  //编辑器外部操作
	  var active = {
	    content: function(){
	      alert(layedit.getContent(index)); //获取编辑器内容
	    },
	    text: function(){
	      alert(layedit.getText(index)); //获取编辑器纯文本内容
	    },
	    selection: function(){
	      alert(layedit.getSelection(index));
	    }
	  };
	  
	  $('.site-demo-layedit').on('click', function(){
	    var type = $(this).data('type');
	    active[type] ? active[type].call(this) : '';
	  });
  
   }); */

   /*]]>*/     
</script>
</html>